// Date:   Wed Aug 13 05:54:24 PM 2025
// Mail:   lunar_ubuntu@qq.com
// Author: https://github.com/xiaoqixian

#pragma once

#include <atomic>
#include <openvino/runtime/core.hpp>
#include <thread>
#include <opencv2/opencv.hpp>

#include "config.hpp"
#include "sampler.hpp"

class Detector {
public:
  Detector(Config config, Context context);

  static void worker(Detector*, size_t ch_id);

  void start();
  void stop();
  void wait();

  Sampler sampler_;
  Config config_;
  Context ctx_;
  DataPipe<ActionShot>* shot_stream_;
  
  ov::Core ov_core_;
  ov::CompiledModel filter_model_, yolo_model_;
  int filter_input_width_, filter_input_height_;
  float filter_conf_thresh_, filter_nms_thresh_;

  int yolo_input_width_, yolo_input_height_;
  float yolo_conf_thresh_, yolo_nms_thresh_;

  std::thread log_th_;
  std::vector<std::thread> workers_;
  std::atomic_bool stopped_ {false};
};
